package com.stephenone.zhdaily.data.source.local;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by Administrator on 2018/2/28.
 */

public class NewsDbHelper extends SQLiteOpenHelper {
    public static final String DATABASE_NAME = "zhihudaily.db";

    public static final int DATABASE_VERSION = 1;

    private static final String TEXT_TYPE = " TEXT";

    private static final String BOOLEAN_TYPE = " INTEGER";

    private static final String INTEGER_TYPE = " INTEGER";

    private static final String LONG_TYPE = " INTEGER";

    private static final String COMMA_SEP = ",";

    public static final String SQL_CREATE_NEWS =
            "CREATE TABLE " + NewsPersistenceContract.NewsEntry.TABLE_NAME + " (" +
                    NewsPersistenceContract.NewsEntry.COLUMN_NAME_DATE + TEXT_TYPE + " PRIMARY KEY," +
                    NewsPersistenceContract.NewsEntry.COLUMN_NAME_JSON + TEXT_TYPE +
            " )";

    public NewsDbHelper(Context context){
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(SQL_CREATE_NEWS);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
